﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record DeleteRoleCommand(long Id) : IRequest<DeleteRoleResult>;

    public class DeleteRoleCommandHandler : IRequestHandler<DeleteRoleCommand, DeleteRoleResult>
    {
        private readonly IRoleService _roleService;
        public DeleteRoleCommandHandler(IRoleService roleService) 
            => _roleService = roleService;

        public async Task<DeleteRoleResult> Handle(DeleteRoleCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.DeleteRoleAsync(request.Id);
        }
    }
}
